// https://vitejs.dev/config/
import { defineConfig } from 'vite'

import { envResolver, commonConfig } from './build/index'

// 打包配置函数，改用函数可以获取到打包环境变量mode
// TODO: 怎么定义这个配置函数的参数类型推导
const modeConfigFn = ({ mode }: { mode: string }) => {
  const fn = envResolver.get(mode) || (() => {})
  return Object.assign(commonConfig, fn())
}
export default defineConfig(modeConfigFn)
